package main

import (
	"log"
	"os"
	"path/filepath"
)

var (
	packageName string
	baseInfos map[string][]string
	infos []*structInfo
	writer *TextWriter
)

const base = "D:\\projectSource\\mi\\compiler"
func abs(path string) string {
	res, err := filepath.Abs(path)
	if err != nil {
		log.Fatal(err)
	}
	return res
}

func main(){
	do("ast_is", filepath.Join(base, "ast/node.go"), filepath.Join(base, "ast/is.go"))
}

func do(kind string, inPath, outPath string) {
	packageName, baseInfos, infos = getCodeInfo(inPath)
	writer = createTextWriter()

	switch kind {
	case "ast_is":
		doAstIsCreate()
	}

	fd, err := os.Create(outPath)
	if err != nil {
		log.Fatal(err)
	}
	defer fd.Close()
	_, err = fd.WriteString(writer.GetText())
	if err != nil {
		log.Fatal(err)
	}
}